<?php defined('SYSPATH') or die('No direct script access.');
 
class Model_Aadmins extends ORM {
	protected $_table_name = 'admins';

	public function currentUser() {
		return DB::select()
			->from('admins')
			->where('id', '=', Cookie::get('admin', null))
			->execute()
			->as_array();
	}

    public function params() {
        return array(
        	'model' => 'Aadmins',
        	'table' => 'admins',
            'fields' => array(
                'fio' => array(
                    'title' => 'ФИО',
                    'type' => 'text',
                    'name' => 'fio',
                ),
                'login' => array(
                    'title' => 'Логин',
                    'type' => 'text',
                    'name' => 'login',
                ),
                'pass' => array(
                    'title' => 'Пароль',
                    'type' => 'password',
                    'name' => 'pass',
                ),
                'role' => array(
                    'title' => 'Роль',
                    'type' => 'select',
                    'name' => 'role',
                    'select_params' => array(
                        'values' => array('0' => 'Суперадмин', '1' => 'Админ'),
                    )
                ),
            ),
            'search_indexes' => array(
                array('field' => 'fio', 'title' => 'ФИО'),
                array('field' => 'login', 'title' => 'Логин'),
            ),
            'main_title' => 'Пользователи',
            'waymark' => 'fio',
        );
    }
}